package com.google.bling.client;

import com.google.bling.client.widget.BlingClient;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.Window;
import com.google.gwt.user.client.ui.RootPanel;

import java.util.List;
import java.util.Map;

/**
 * Entry point classes define <code>onModuleLoad()</code>.
 */
public class Bling implements EntryPoint {

  /**
   * This is the entry point method.
   */
  public void onModuleLoad() {
//    // The only new code we've added to GWT's demo app
//	  new TransactionsChannel().request(10, new TransactionsCallback() {
//		public void execute(TransactionsChannel.Response o) {
//			Window.alert("participants: " + o.participants);
//			Window.alert("before: " + o.before);
//			Window.alert("transactions: " + o.transactions.toString());
//			Window.alert("after: " + o.after);
////		  RootPanel.get().add(new BlingClient("A", o.participants, Util.makeHash(o.participants, o.before)));
//		}});

    new AddTransactionChannel().request(
    		42,
			"appleton,koz,macpherson",
			"title",
			1000,
			"appleton",
			"500,-250,-250",
			new AddTransactionCallback() {
    			public void execute(AddTransactionChannel.Response o) {
    				Window.alert("AddTransactionChannel responded!");
    			}});

    List<String> otherUsers = Util.list();
    otherUsers.add("appleton");
    otherUsers.add("koz");
    otherUsers.add("macpherson");

    String currentUser = "couk";

    List<String> allUsers = Util.list(currentUser);
    allUsers.addAll(otherUsers);

    List<Integer> before = Util.list(0, -100, -250, 300);


    Map<String, Integer> bbf = Util.makeHash(allUsers, before);

    RootPanel.get().add(new BlingClient(currentUser, allUsers, bbf));
  }
}
